from rest_framework import serializers
from .models import PersonInfo, Vocation

nameList = PersonInfo.objects.values('name').all()
NAME_CHOICES = [item['name'] for item in nameList]

class MySerializer(serializers.Serializer):
    id = serializers.IntegerField(read_only=True)
    job = serializers.CharField(max_length=100)
    tittle = serializers.CharField(max_length=100)
    payment = serializers.IntegerField()
    name = serializers.PrimaryKeyRelatedField(queryset=PersonInfo.objects.all())

    def create(self, validated_data):
        return Vocation.objects.create(**validated_data)

    def update(self, instance, validated_data):
        return instance.update(**validated_data)
